package com.myteam.fugaocrm.sqldb.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.myteam.fugaocrm.modle.FgStaff;

/**
 * 员工Mapper
 * @author BZX
 */
public interface FgStaffMapper {

	/** 查询全部员工 */
	@Select(
		"select "
		+ "staff.*,  company.company_name, position.position_name "
		+ "from fg_staff staff "
		+ "left join fg_company company on staff.company_id = company.company_id "
		+ "left join fg_position position on staff.position_id = position.position_id "
		+ "where staff.is_delete = 0")
	public List<FgStaff> all();
	
	/** 删除一个员工 */
	@Select("update fg_staff set is_delete = 1 where staff_id = #{staffId}")
	public void deleteOne(@Param("staffId") Integer staffId);
	
	/** 注册一个员工 */
	@Insert("INSERT into fg_staff(user_id,staff_name,staff_mobile,permission,created_date,created_user,modified_date,modified_user) VALUES(#{userId},#{staffUame},#{staffMobile},#{permission},#{createdDate},#{createdUser},#{modifiedDate},#{modifiedUser})")
	public void insert(Map<String, Object> params);
	
	/** 修改一个员工 */
	@Select("update fg_staff set company_id=#{companyId},position_id=#{positionId},permission=#{permission},modified_user=#{modifiedUser},modified_date=#{modifiedDate} where staff_id = #{staffId}")
	public void update(Map<String, Object> params);
	
	/** 修改员工手机 */
	@Select("update fg_staff set staff_mobile=#{staffMobile},modified_user=#{modifiedUser},modified_date=#{modifiedDate} where staff_id = #{staffId}")
	public void updateMobile(Map<String, Object> params);
	
	
	/** 根据员工ID查询员工 */
	@Select("SELECT * FROM fg_staff WHERE user_id = #{userId}")
	public FgStaff selectStaffByUserId(@Param("userId") Integer userId);
	
	/** 根据员工表ID查询员工 */
	@Select("SELECT * FROM fg_staff WHERE staff_id = #{staffId}")
	public FgStaff selectStaffByStaffId(@Param("staffId") Integer staffId);
}
